<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>通知公告</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <link href="/wangeditor-5.1.23/style.css" rel="stylesheet">
    <script src="/wangeditor-5.1.23/index.js" charset="utf-8"></script>
    <style>
        body { background-color: #ffffff; }
        #editor—wrapper {
            border: 1px solid #ccc;
            z-index: 100; /* 按需定义 */
        }
        #toolbar-container { border-bottom: 1px solid #ccc; }
        #editor-container { height: 300px; }
    </style>
</head>
<body>

<div class="layui-form layuimini-form" id="app">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"><legend>{{detail.id?'编辑':'添加'}}</legend></fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label required">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" :value="detail.title" class="layui-input layui-disabled" readonly="true">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">配置值</label>
        <div class="layui-input-block">
            <textarea name="val" class="layui-textarea" style="height:260px;">{{detail.val}}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" id="submitBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script>
var Id = urlParam("id")

layui.use(['form'], function () {
    var form = layui.form, layer = layui.layer, $ = layui.$;
    new Vue({
        el:"#app",
        data:{
            detail:{
                id:Id
            }
        },
        methods:{

        },
        mounted:function(){
            var _this = this;
            var id = urlParam("id")
            $.get('/admin/gameSetting/'+id,{},function (res) {
                _this.detail = res.data
            })
            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var formData = data.field;
                if (id) formData._method = 'put';
                $.post('/admin/gameSetting/'+id,formData,function (res) {
                    if (res.code === 0 ){
                        layer.msg('操作成功',{icon:6,time:500},function () {
                            parent.location.reload();
                        })
                    }
                })
                return false;
            });
        },
        updated:function(){
            form.render();
        }
    })
});
</script>
</body>
</html>